home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / blankery / mblank / module.i < prev    next >
Text File  |  1982-08-01  |  8KB  |  256 lines

  1. ;$VER: module.i 1.22 (28-02-1997) damian@cybercomm.nl
  2.  
  3. nb_SIZEOF        EQU    26    ;why not in includes?
  4. LINK_KIND        EQU    10    ;next gadget to the right of previous
  5. OFF_KIND        EQU    15    ;following gadget disabled
  6.  
  7. ;------------------------------ GENERAL -----------------------------------
  8.  
  9. ;Custom blanker-modules:
  10. ;input:        a5    =    APTR Globals (saved/restored before/after
  11. ;                calling you blanker code.)
  12. ;output:    status register's zeroflag SET on failure, UNSET
  13. ;        on succes:    moveq #TRUE,d0
  14. ;                rts        ;succesfull exit
  15.  
  16. ;                moveq #FALSE,d0
  17. ;                rts        ;unsuccesfull exit
  18. ;        in the latter case, MBlank will use its internal
  19. ;        'Black-Screen' as a backup.
  20.  
  21. ;Your code MUST be 100% position-independant.
  22.  
  23. ;--------------------------- MODULE STRUCTURE --------------------------------
  24.  
  25. ;Blanker module structure, equates, flags etc.
  26.  STRUCTURE BlmSimple,0
  27.  
  28.     LONG    blm_ID        ;allways 'BLMS' for simples, other types
  29.                 ;may be added in future.
  30.     LONG    blm_Length    ;length of module-file in bytes.
  31.     BPTR    blm_Code    ;code-entry of your module, MUST be relative
  32.                 ;to module start. (blm_structure)
  33. ;blm_Info not yet implemented, set to NULL for backwards compatibility.
  34.     APTR    blm_Info    ;currently unused, set to NULL
  35.     APTR    blm_Settings    ;set to NULL if you don't support.
  36.     APTR    blm_Extend    ;currently unused, set to NULL
  37.     BYTE    blm_Flags    ;general flags field. Set to NULL for BWC.
  38.     BYTE    blm_Pad1
  39.     WORD    blm_Pad2
  40.     LABEL    blm_SIZEOF    ;This size will remain constant.
  41.  
  42. ;SETTINGS structures
  43. ;all pointers must be relative to module address
  44.  STRUCTURE ModSlide,0
  45.     APTR    slide_TTName    ;tooltype name, so MBlank can parse
  46.     LONG    slide_Default    ;used if tooltype 'TTName' not found
  47.     LONG    slide_Min    ;
  48.     LONG    slide_Max    ;
  49.     APTR    slide_GText    ;gadget text, if NULL single height used
  50.     LABEL    slide_SIZE
  51.  
  52.  STRUCTURE ModCycle,0
  53.     APTR    cycle_TTName    ;tooltype 'NAME'
  54.     LONG    cycle_Default    ;ordinal number of selected item (0 - ...)
  55.     LONG    cycle_Count    ;number of items
  56.     APTR    cycle_GText    ;gadget text
  57.     LABEL    cycle_SIZEOF
  58.     APTR    cycle_Items    ;the rest are #Count APTRs to item
  59.                 ;texts which should match the tooltype
  60.                 ;values exactly, so MBlank can find out
  61.                 ;what the current setting is and set it.
  62. ;   APTR    cycle_Item...    ;etc.
  63. ;   APTR    NULL-termination
  64.  
  65.  STRUCTURE ModCheck,0
  66.     APTR    check_TTName
  67.     LONG    check_Default    ;TRUE or FALSE
  68.     APTR    check_GText
  69.     LABEL    check_SIZE
  70.  
  71.  STRUCTURE ModString,0
  72.     APTR    string_TTName    ;value will be initial contents of string
  73.     APTR    string_GText
  74.     LABEL    string_SIZE
  75.  
  76. ;--------------------------- GLOBAL STRUCTURE ---------------------------------
  77. ;Instructions on using the AllGlobals(a5) structure:
  78.  
  79. ;- PRIVATE    Blanker modules may not use these in any way!
  80. ;- LIB        A library pointer which is valid. (blanker modules run
  81. ;        on the same context as the Process which opened the Libs.)
  82. ;        Don't close these Libs. under any circumstance.
  83. ;- READ        May be read, contents are valid.
  84. ;- USE        Space may be used, contents may not be valid!
  85. ;- CHANGE    May be set, according to rules.
  86.  
  87. ; A module can Wait() on the gb_ResetSignal(a5) if it doesn't have to keep
  88. ; working. You can ofcourse also poll this signal.
  89. ; If the module does polling to determine wether or not a significant
  90. ; input-event ocurred, use btst #GB_BLANK,gb_Flags(a5).(beq ABORT_blanking).
  91.  
  92. ; The gb_Random(a5) pointer is a pointer to a pseudo-random generator, which
  93. ; I copied from one of Toby Simpson's example Lottery programs.(Shopper)
  94. ; input:    d0.w    =    maximum value (1 to 65535).
  95. ; All registers get saved/restored, therefore the gb_Random entry can
  96. ; easily be used from within iterations.
  97. ; output:    d0.w    =    Random number (0 to maximum value-1).
  98.  
  99. ; variables/pointers/structures
  100.  STRUCTURE AllGlobals,0
  101.     STRUCT    gb_NewBrokerStruct,nb_SIZEOF
  102.     BYTE    gb_ExtFlags
  103.     BYTE    gb_ActionFlags
  104.     STRUCT    gb_HotKeyIX,ix_SIZEOF
  105.     APTR    gb_WBstartupMsg
  106.     APTR    gb_Broker
  107.     APTR    gb_WBLock
  108.     APTR    gb_Screen
  109.     APTR    gb_VisInfo
  110.     APTR    gb_Menu
  111.     APTR    gb_Window
  112.     APTR    gb_BitMap
  113.     APTR    gb_DiskObject    ;READ, if MBlank found your mod's icon, its
  114.                 ;address is stored here.(DO NOT FREE!)
  115.     APTR    gb_Process
  116.     APTR    gb_AppItem
  117.     APTR    gb_ModLock
  118.     APTR    gb_FIB
  119.     APTR    gb_ModHandle
  120.     APTR    gb_Module    ;READ, address of your module
  121.     APTR    gb_Random    ;READ, entry point to pseudo random-number
  122.                 ;generator. (Toby Simpson)
  123.     LONG    gb_ModType
  124.     LONG    gb_ModSize
  125.     APTR    _IconBase    ;LIB, you can use all of the following
  126.     APTR    _IntBase    ;LIB, pointers as if you had opened the
  127.     APTR    _CxBase        ;LIB, libraries yourself. NEVER close
  128.     APTR    _DOSBase    ;LIB, these libraries!!! You don't have
  129.     APTR    _WBBase        ;LIB, to check these pointers first, if
  130.     APTR    _GTBase        ;LIB, MBlank has come this far, ALL libs
  131.     APTR    _GfxBase    ;LIB, will have opened. (versions 37+ min.).
  132.     LONG    gb_OldDir
  133.     LONG    gb_Ticks
  134.     LONG    gb_Counter
  135.     LONG    gb_Delay
  136.     LONG    gb_Store    ;USE, used by ToolType macros
  137.     LONG    gb_SigNums
  138.     LONG    gb_CountSignal
  139.     LONG    gb_PopSignal
  140.     LONG    gb_ResetSignal    ;READ, WAIT() on this one, or poll
  141.     BYTE    gb_CountSigNum
  142.     BYTE    gb_PopSigNum
  143.     BYTE    gb_ResetSigNum    ;READ, the bitnumber of the above
  144.     BYTE    gb_Flags    ;READ, btst #GB_BLANK,gb_Flags(a5), beq Quit
  145.     STRUCT    gb_ModPath,128
  146.     STRUCT    gb_ModName,32
  147.     STRUCT    gb_User,512    ;USE, space can be used, contains path/name
  148.                 ;to your module on entry
  149.  
  150. ;Do NOT rely on the size of this structure, it may be extended.
  151. ;In fact, internally it allready has been extended for MBlank itself.
  152.  
  153. ;gb_Flags:        Bit:    Flagging:
  154. GB_BLANK    EQU    4    ;if CLEAR, blanking should abort right now,
  155.                 ;but first CLEAN UP EVERYTHING.!
  156.  
  157. ;--------------------------- TOOLTYPE MACROS -------------------------------
  158.  
  159. ;Macros for convenience and clarity
  160. ;FINDTT        -    Checks existence of a tooltype
  161. ;Example usage:    FINDTT    ALERT
  162. ;        beq.s    NotFound
  163. ;        ...    ...
  164. ;ALERT        dc.b    'ALERT',NULL
  165.  
  166. ;Always tst.l gb_DiskObject(a5) first, maybe MBlank didn't get it!
  167.  
  168. FINDTT        MACRO
  169.         move.l    gb_DiskObject(a5),a0
  170.         move.l    do_ToolTypes(a0),a0
  171.         lea    \1(pc),a1
  172.         CALLIC    FindToolType
  173.         tst.l    d0
  174.         ENDM
  175.  
  176. ;TTVAL        -    Translates a number tooltype value and stores
  177. ;            it in the global-structure.
  178. ;Template:    TTVAL    offset,size,minimum,maximum
  179. ;            (defaults should be set in advance!)
  180. ;function:    can be used directly after FINDTT, translates a string
  181. ;        to an integer and stores it in <variable>(a5).
  182. ;offset:    must be a field in the (a5) AllGlobals structure.
  183. ;size:        b, w, l. (byte, word, long)
  184. ;minimum:    if<minimum, uses default. (not changed)
  185. ;maximum:    if>maximum, uses default. (not changed)
  186.  
  187. ;for example:    Handle SPHERES tooltype
  188. ;        FINDTT    TT_SPHERES
  189. ;        TTVAL    bog_Spheres,w,1,30,10
  190. ;        ...    ...
  191. ;TT_SPHERES    dc.b    'SPHERES',NULL
  192.  
  193. ;The above two lines will:    -check the existence of 'SPHERES' tooltype
  194. ;                    -read the tooltype value
  195. ;                    -check its range and validity, if ok
  196. ;                    -move.w #result,bog_Spheres(a5)
  197. ;                -end
  198.  
  199. _ttvalused    set    0
  200. TTVAL        MACRO
  201.         beq.s    TTMnext\<_ttvalused>    ;not found by FINDTT
  202.         move.l    d0,d1            ;found it, extract value
  203.         lea    gb_Store(a5),a0
  204.         move.l    a0,d2
  205.         CALLDOS    StrToLong    ;gb_Store=longalligned, don't worry.
  206.         tst.l    d0
  207.         ble.s    TTMnext\<_ttvalused>    ;no digits found, default
  208.         move.l    gb_Store(a5),d0        ;StrToLong results
  209.         cmp.\2    #\3,d0            ;no smaller than \3 argument
  210.         bcs.s    TTMnext\<_ttvalused>    ;otherwise default used
  211.         cmp.\2    #\4,d0            ;no larger than \4 argument
  212.         bhi.s    TTMnext\<_ttvalused>    ;otherwise default used
  213.         move.\2    d0,\1(a5)
  214. TTMnext\<_ttvalused>    
  215. _ttvalused    set    _ttvalused+1
  216.         ENDM
  217.  
  218. ;--------------------------- MISCELLENEOUS -------------------------------
  219.  
  220. ;handy macros
  221. CALLDOS        MACRO                ;call dos.library
  222.         move.l    _DOSBase(a5),a6
  223.         jsr    _LVO\1(a6)
  224.         ENDM
  225.  
  226. CALLINT        MACRO                ;call intuition.library
  227.         move.l    _IntBase(a5),a6
  228.         jsr    _LVO\1(a6)
  229.         ENDM
  230.  
  231. CALLGFX        MACRO                ;call graphics.library
  232.         move.l    _GfxBase(a5),a6
  233.         jsr    _LVO\1(a6)
  234.         ENDM
  235.  
  236. CALLEXEC    MACRO                ;call the almighty
  237.         movea.l    (4),a6
  238.         jsr    _LVO\1(a6)
  239.         ENDM
  240.  
  241. CALLEX        MACRO
  242.         move.l    (4),a6
  243.         jsr    _LVO\1(a6)
  244.         ENDM
  245.  
  246. CALLIC        MACRO                ;call icon.library
  247.         move.l    _IconBase(a5),a6
  248.         jsr    _LVO\1(a6)
  249.         ENDM
  250.  
  251. CALLWB        MACRO                ;call workbench.library
  252.         move.l    _WBBase(a5),a6
  253.         jsr    _LVO\1(a6)
  254.         ENDM
  255.  
  256.